<template>
    <IDrawer v-model="defaultValue" :loading="loading" :width="500" title="账册表体">
        <Form :model="data" :label-width="100" :rules="ruleValidate" ref="formCreate">
            <FormItem label="账册表体" prop="file">
                <UploadInput url="common/index/upload" v-model="data.file"></UploadInput>
            </FormItem>
        </Form>
        <div slot="footer">
            <Button type="primary" icon="ios-add" @click="submit('formCreate')">提交</Button>
            <Button type="warning" icon="md-log-out" @click="defaultValue = false;">返回</Button>
        </div>
    </IDrawer>
</template>

<script>
    import IForm from "../../../components/content/form";
    import contentDrawer from "../../../mixins/contentDrawer";
    import IDrawer from "../../../components/content/modal";
    import RemoteSelect from "../../../components/form/remoteSelect";
    import UploadInput from "../../../components/form/upload-input";

    export default {
        name: "IExport",
        mixins: [contentDrawer],
        components: {UploadInput, RemoteSelect, IForm, IDrawer},
        data() {
            return {
                data: {},
                ruleValidate: {
                    file: [{required: true, message: '文件必须上传'}]
                },
            }
        },
        methods: {
            submit(data) {
                this.validate(data).then(() => {
                    this.loading = true;
                    this.$http.post(`product/book`, this.data).then(() => {
                        this.defaultValue = false;
                    }).catch((res) => {
                        console.log(res)
                    }).finally(() => {
                        this.loading = false;
                    });
                });
            }
        }
    }
</script>

<style scoped>

</style>
